using System;
using System.Windows.Forms;

using FreeFlow;
using FreeFlow.Administration;

namespace FreeFlowAdministrator
{
	/// <summary>
	/// Summary description for ActionAdaptor.
	/// </summary>
	public class ActionAdaptor : Adaptor
	{
    private Action action;
		public ActionAdaptor(Action action)
		{
      this.action = action;
		}

    public override string Text
    {
      get
      {
        return action.Name;
      }
    }

    public override Control GetRenderer()
    {
      ActionControl control = new ActionControl();
      control.LoadAction(action);
      return control;
    }

    public override int ImageIndex
    {
      get
      {
        // different images for different action types
        switch (action.ActionType)
        {
          case ActionType.User : return 0;
          case ActionType.Timed : return 19;
          case ActionType.Conditional : return 20;
          case ActionType.Flagged : return 21;
          case ActionType.Rendezvous : return 22;
          default : throw new FreeFlowException("Unrecognized action type - " + action.ActionType);
        }
      }
    }

    public override object Object
    {
      get
      {
        return action;
      }
    }
	}
}
